package com.xxrl.shop.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.hibernate.annotations.Proxy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;

/**
 * @author mis
 * 都是迫切查询 实现比较渣
 * 是否付款
 * 物流状态
 * 用户评论
 */
@ApiModel(description = "Address information of user.")
@Data
@Entity
@ToString
@Proxy(lazy = false)
@NoArgsConstructor
@Table(name = "sp_order")
@EntityListeners(AuditingEntityListener.class)
public class Order implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(notes = "Unique identifier of the Order.", example = "1", required = true)
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne
    @JoinColumn(name = "user_id")
    private User user;

    @ManyToOne
    @JoinColumn(name = "product_id")
    private Product product;
    @ManyToOne
    @JoinColumn(name = "address_id")
    private Address address;

    @ApiModelProperty(notes = "This order has payed", example = "false")
    private Boolean pay;
    @ApiModelProperty(notes = "Order status(send, received)", example = "send")
    private String status;
    @ApiModelProperty(notes = "Comment of order write by buyer.", example = "Very good product")
    private String comment;
    @ApiModelProperty(notes = "Count of bought products.", example = "1")
    private Integer productNum;

    private Double rating;

    @CreatedDate
    private Long createTime;

    @LastModifiedDate
    private Long lastModifiedTime;
    
    public Order(Long id) {
        this.id = id;
    }

}
